package com.x52im.rainbowchat.http.dao;

import com.alipay.api.response.AlipayTradeAppPayResponse;
import com.eva.framework.dbpool.DBShell;
import com.x52im.rainbowchat.BaseConf;
import com.x52im.rainbowchat.http.logic.dto.AlipayDepositDTO;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class AlipayDAO {
    DBShell db = new DBShell();

    public List<Map<String, Object>> queryDepositListAndCashList(String userUid) throws Exception {
//        String sql = String.format("select * from (" +
//                "select id, total_amount , gmt_payment state_date, 'deposit' type from alipay_deposit_notify where user_uid=%s " +
//                "union all " +
//                "select id, trans_amount total_amount, trans_date state_date, 'cash' type from alipay_cash where user_uid =%s " +
//                ") x order by x.state_date desc", userUid, userUid);

        String sql = String.format("select case a.`type` when 'AD' then 'deposit' when 'AC' then 'cash' when 'RS' then 'redSend' when 'RG' then 'redGet' end type ," +
                "a.type_id id ,CAST(a.change_amount/100 as DECIMAL(18,2)) total_amount, a.state_date  " +
                "from missu_account_his a where a.user_uid =%s order by a.state_date desc ", userUid);
        List<Map<String, Object>> list = db.queryDataListMap(sql);
        return list;
    }

}
